{php include wl_template('common/header');}
<script type="text/javascript" src="{URL_WEB_JS}diyarea.js"></script>
<ul class="nav nav-tabs" id="myTab">
	<li class="active" ><a href="#tab_1">基本信息</a></li>
	<li><a href="#tab_2">区域设置</a></li>
	<li><a href="#tab_3">结算提现</a></li>
</ul>
<div class="app-content">
<div class="app-form">
	<form action="" method="post" class="form-horizontal form form-validate">
		<input type="hidden" name="id" value="{$agent['id']}" />
		<div class="tab-content">
            <!--代理商基本信息-->
			<div class="tab-pane  active" id="tab_1">
				<div class="panel panel-default">
					<div class="panel-heading">
						代理信息
					</div>
					<div class="panel-body">
						<div class="form-group">
				    		<label class="col-sm-2 control-label">代理名称<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[agentname]" required placeholder="请输入代理名称" class="form-control" value="{$agent['agentname']}">
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">真实姓名<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[realname]" required placeholder="请输入真实姓名" class="form-control" value="{$agent['realname']}">
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">联系电话</label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[mobile]" placeholder="请输入联系电话" class="form-control" value="{$agent['mobile']}">
				    		</div>
				  		</div>
					</div>
				</div>
				<div class="panel panel-default">
					<div class="panel-heading">
						代理账号
					</div>
					<div class="panel-body">
						{if !empty($agent['id'])}
						<div class="form-group">
				    		<label class="col-sm-2 control-label">代理账号<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[username]" required placeholder="请输入代理账号" class="form-control" value="{$agent['username']}">
				      			<span class="help-block">当前编辑的用户名</span>
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">新密码</label>
				    		<div class="col-sm-9">
				      			<input type="text" name="password" placeholder="请输入代理新密码" class="form-control" value="">
				      			<span class="help-block">请填写密码，最小长度为 8 个字符。如果不更改密码此处请留空</span>
				    		</div>
				  		</div>
				  		{else}
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">代理账号<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[username]" required placeholder="请输入代理账号" class="form-control" value="">
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">代理密码<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<input type="text" name="agent[password]" required placeholder="请输入代理密码" class="form-control" value="">
				    		</div>
				  		</div>
				  		{/if}
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">所属组别<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			<select name="agent[groupid]" class="form-control">
		        					{loop $allgroup $groups}
		        					<option value="{$groups['id']}" {if $groups['id'] == $agent['groupid']}selected{/if}>{$groups['name']}</option>
		        					{/loop}
		      					</select>
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">到期时间<span class="must-fill">*</span></label>
				    		<div class="col-sm-9">
				      			{php echo tpl_form_field_date('agent[endtime]',$agent['endtime'])}
				    		</div>
				  		</div>
				  		<div class="form-group">
				    		<label class="col-sm-2 control-label">是否启用</label>
				    		<div class="col-sm-9">
				    			<label class="radio-inline">
                                    <input type="radio" value="1" name="status" {if $agent['status']==1}checked{/if}>是
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" value="0" name="status" {if $agent['status']==0}checked{/if}>否
                                </label>
				    		</div>
				  		</div>
					</div>
				</div>
			</div>
            <!--代理商代理区域设置-->
			<div class="tab-pane" id="tab_2">
				<div class="panel panel-default">
					<div class="panel-heading">
						代理区域
					</div>
					<div class="panel-body">
			  			<div class="form-group">
				    		<label class="col-sm-2 control-label">地区等级</label>
				    		<div class="col-sm-9">
				    			<label class="radio-inline" onclick="$('#tpl-district').hide();$('#tpl-city').hide();$('#tpl-town').hide();">
                                    <input type="radio" value="1" name="districtslevel" {if $area['level']==1}checked{/if}>一级
                                </label>
                                <label class="radio-inline" onclick="$('#tpl-district').hide();$('#tpl-city').show();$('#tpl-town').hide();">
                                    <input type="radio" value="2" name="districtslevel" {if $area['level']==2 || empty($area['level'])}checked{/if}>二级
                                </label>
                                <label class="radio-inline" onclick="$('#tpl-district').show();$('#tpl-city').show();$('#tpl-town').hide();">
                                    <input type="radio" value="3" name="districtslevel" {if $area['level']==3}checked{/if}>三级
                                </label>
                                <label class="radio-inline" onclick="$('#tpl-district').show();$('#tpl-city').show();$('#tpl-town').show();">
                                    <input type="radio" value="4" name="districtslevel" {if $area['level']==4}checked{/if}>四级
                                </label>
				    		</div>
				  		</div>
				  		<div class="form-group">
							<label class="col-sm-2 control-label">运营地区</label>
							<div class="col-sm-9">
								<div class="row row-fix js-address-selector selectArea">
									<div class="col-md-3" id="tpl-province">
										<select name="districts[province]" data-value="{$districts['province']}" level="1" class="form-control tpl-province changeArea">
                                            {loop $province $item}
                                                <option value="{$item['id']}" {if $item['id'] == $province_id}selected="selected"{/if}>{$item['name']}</option>
                                            {/loop}
                                        </select>
									</div>
									<div class="col-md-3" {if $area['level'] == 1}style="display: none;"{/if} id="tpl-city">
										<select name="districts[city]" data-value="{$districts['city']}" level="2"  class="form-control tpl-city changeArea">
                                            {loop $city $item}
                                                <option value="{$item['id']}" {if $item['id'] == $city_id}selected="selected"{/if}>{$item['name']}</option>
                                            {/loop}
                                        </select>
									</div>
									<div class="col-md-3" {if $area['level'] <= 2}style="display: none;"{/if} id="tpl-district">
										<select name="districts[district]" data-value="{$districts['district']}" level="3"  class="form-control tpl-district changeArea">
                                            {loop $district $item}
                                                <option value="{$item['id']}" {if $item['id'] == $district_id}selected="selected"{/if}>{$item['name']}</option>
                                            {/loop}
                                        </select>
									</div>
									<div class="col-md-3" {if $area['level'] <= 3}style="display: none;"{/if} id="tpl-town">
										<select name="districts[town]" data-value="{$districts['town']}" level="4"  class="form-control tpl-town changeArea">
                                            {loop $town $item}
                                                <option value="{$item['id']}" {if $item['id'] == $town_id}selected="selected"{/if}>{$item['name']}</option>
                                            {/loop}
                                        </select>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
            <!--代理商结算提现设置-->
			<div class="tab-pane" id="tab_3">
				<div class="panel panel-default">
					<div class="panel-heading">
						代理提现到微信号
					</div>
					<div class="panel-body">
						<div class="form-group">
							<label class="col-sm-2 control-label">代理微信</label>
							<div class="col-sm-9">
								{php echo tpl_select_user('agent[cashopenid]', $agent['cashopenid']);}
							</div>
						</div>
					</div>
				</div>
				<div class="panel panel-default">
					<div class="panel-heading">
						商家提现设置
					</div>
					<div class="panel-body">
						<div class="form-group">
							<label class="col-sm-2 control-label" >系统提成</label>
							<div class="col-sm-9">
								<div class="input-group">
									<input type="text" name="percent[syssalepercent]" class="form-control" value="{$agent['percent']['syssalepercent']}" />
									<span class="input-group-addon">%</span>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				<div class="panel panel-default">
					<div class="panel-heading">
						代理提现设置
					</div>
					<div class="panel-body">
						<div class="form-group">
							<label class="col-sm-2 control-label" >系统提成</label>
							<div class="col-sm-9">
								<div class="input-group">
									<input type="text" name="percent[agentpercent]" class="form-control" value="{$agent['percent']['agentpercent']}" />
									<span class="input-group-addon">%</span>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label"></label>
			<div class="col-sm-9">
				<input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
				<input type="hidden" name="token" value="{$_W['token']}" />
			</div>
		</div>
	</form>
</div>
</div>
<script type="text/javascript">
	$(function () {
		window.optionchanged = false;
		$('#myTab a').click(function (e) {
			e.preventDefault();//阻止a链接的跳转行为
			$(this).tab('show');//显示当前选中的链接及关联的content
		})
	});
</script>
{php include wl_template('common/footer');}